<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding: 0;
        }
        #btn{
            width: 200px;
            height: 50px;
        }
        .box{
            height: 3000px;
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <input type="button" id="btn" value="回到顶点">
</body>
<script>
    var btn = document.getElementById("btn");
    btn.onclick = function(){
        document.documentElement.scrollTop = 0 ;
    }
</script>
</html>